package com.cxf.cxfuserone.feign;

import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * description: StoreFeignClientHystrixFactory <br>
 * date: 2021/11/1 19:41 <br>
 * author: cxf <br>
 * version: 1.0 <br>
 */
@Component
public class StoreFeignClientHystrixFactory implements FallbackFactory<StoreFeignClient> {

    private static final Logger logger = LoggerFactory.getLogger(StoreFeignClientHystrixFactory.class);

    @Override
    public StoreFeignClient create(Throwable throwable) {
        return new StoreFeignClient() {


            @Override
            public String echoYourMessageFromUserOne(String msg) {
                logger.error("FallbackFactory message error ...",throwable);
                return "  FallbackFactory   hystrix echoYourMessageFromUserOne msg " ;
            }

            @Override
            public String echoYourMessage(String user, String pwd) {
                logger.error(" FallbackFactory   echoYourMessage user pwd error  ........");
                return " FallbackFactory echoYourMessage user pwd";
            }

            @Override
            public String loginByMap(Map<String, Object> map) {
                return " FallbackFactory loginByMap  map";
            }
        };
    }
}
